#include <ctype.h>
#include <limits.h>
#include <math.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

#include "uthash.h"

#include <iso646.h>

/**
 * Definition for singly-linked list.
 */
struct ListNode {
	int val;
	struct ListNode* next;
};
typedef struct ListNode list_node, *list_node_p;

typedef struct {
	int* arr;
	size_t size;
} Solution;

Solution* solutionCreate(struct ListNode* head)
{
	size_t size = 0;
	for (list_node_p p = head; p; p = p->next) size++;
	Solution o = { (int*)malloc(size * sizeof(int)), size };
	Solution* res = (Solution*)malloc(sizeof o);
	*res = o; int i = 0;
	for (list_node_p p = head; p; p = p->next) o.arr[i++] = p->val;
	return res;
}

int solutionGetRandom(Solution* obj)
{
	srand(time(NULL));
	return obj->arr[rand() % obj->size];
}

void solutionFree(Solution* obj)
{
	free(obj->arr);
	free(obj);
}

/**
 * Your Solution struct will be instantiated and called as such:
 * Solution* obj = solutionCreate(head);
 * int param_1 = solutionGetRandom(obj);

 * solutionFree(obj);
*/

int main()
{
	return 0;
}
